package com.tich.order.controller;

import com.tich.constant.ResponseMessageConstant;
import com.tich.order.service.PayService;
import com.tich.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/pay")
public class PayController {

    @Autowired
    private PayService payService;

    /**
     * 支付订单
     * @param orderId
     * @return
     * */
    @PostMapping
    public Result payOrder(Long orderId){
        log.info("支付订单：{}", orderId);
        payService.payOrder(orderId);
        return Result.success(ResponseMessageConstant.PAY_SUCCESS);
    }

    /**
     * 退款
     * @param orderId
     * @return
     * */
    @PostMapping("/refund")
    public Result refundOrder(Long orderId){
        log.info("退款：{}", orderId);

        return Result.success(ResponseMessageConstant.REFUND_SUCCESS);
    }

}
